home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 8
/
FM Towns Free Software Collection 8.iso
/
t_os
/
artemis
/
artsrc2
/
gpset.asm
< prev
next >
Wrap
Assembly Source File
|
1994-06-01
|
4KB
|
230 lines
; 私製ライブラリ・グラフィック篇
; (c) MATSUUCHI Ryosuke in Dec,1992
;
; gpset.asm
;
; 1992. 6.13(Sat)
; 1992. 7. 9(Thu)
; 1992.12.28(Sun)
public gpset,_gpset
extrn _gwrtreg:near
extrn __SetVramSeg:near, __AddVramBase_ebx:near
include grplib.inc
assume cs:cseg, ds:dseg
dseg segment dword 'DATA'
dseg ends
cseg segment dword 'CODE'
;---------------------------------------------------------------
; _gpset : 点の描画
; in EAX,EBX : 座標
; ECX : 色
; EDX : 演算指定(0=PSET 4=XOR)
;
; void gpset(int x, int y, int col, int mode)
;---------------------------------------------------------------
align 4
_gpset proc
pushad
mov esi,[_nowscrmod] ;esi に画面モードを入れる
cmp si,2
jle #end
cmp si,4
jg #1
call gpset_16
jmp #end
#1: cmp si,8
jg #2
call gpset_32_1
jmp #end
#2: cmp si,11
jg #3
call gpset_32_2
jmp #end
#3: cmp si,14
jg #4
call gpset_256
jmp #end
#4: cmp si,18
jg #end
call gpset_32_3
#end: popad
ret
_gpset endp
gpset proc
push ebx
pushfd
mov eax,[esp+8+4] ;eax に x 座標を入れる
mov ebx,[esp+8+8] ;ebx に y 座標を入れる
mov ecx,[esp+8+12] ;ecx に色を入れる
mov edx,[esp+8+16] ;edx に演算指定を入れる
call _gpset
popfd
pop ebx
ret
gpset endp
align 4
;● PSET のサブルーチン(16色PSET)
;----------------------------------------------------------------------------
gpset_16 proc
mov esi,eax ;edi にマスクパターンを入れる
mov edi,1111b
and esi,7
lea esi,[esi*4]
or esi,esi
jz #1
xchg ecx,esi ;マスクパターンをシフト
shl edi,cl ;ついでにカラーコードも
shl esi,cl ;シフトする。
xchg ecx,esi
and ecx,edi
#1: shr eax,1 ;ebx にアドレスを入れる
and eax,0fffffffch
lea ebx,[ebx*8]
lea ebx,[ebx*8]
lea ebx,[ebx*8+eax]
call __AddVramBase_ebx
push es ;es を保存
call __SetVramSeg ;es ←書き込みページのセレクタ
mov eax,es:[ebx] ;eax に VRAMの内容を入れる
or edx,edx ;edx(演算指定)により分岐
jnz #3
not edi ;PSET演算
and eax,edi
or eax,ecx
jmp #4
#3: cmp edx,4
jnz #5
xor eax,ecx ;XOR演算
jmp #4
#5: cmp edx,6
jnz #4
or ecx,ecx ;MATTE(0透過)演算
jz #6
not edi
and eax,edi
or eax,ecx
#4: mov es:[ebx],eax ;eax の値を VRAM に書き込む
#6: ;
pop es ;es を復帰
ret
gpset_16 endp
;● PSET のサブルーチン(3万色PSET [512*256ピクセルモード])
;----------------------------------------------------------------------------
gpset_32_1 proc
lea ebx,[ebx*8] ;ebx に ebx*512+eax*2 を
lea ebx,[ebx*8] ;入れる(VRAM アドレス)
lea ebx,[ebx*4+eax]
lea ebx,[ebx*2]
call gpset32sub
ret
gpset_32_1 endp
gpset_32_2 proc
lea ebx,[ebx*8] ;ebx に ebx*1024+eax*2 を
lea ebx,[ebx*8] ;入れる(VRAM アドレス)
lea ebx,[ebx*8+eax]
lea ebx,[ebx*2]
call gpset32sub
ret
gpset_32_2 endp
;● PSET のサブルーチン(256色PSET)
;----------------------------------------------------------------------------
gpset_256 proc
;★まだ作ってないよーん
push ds
mov ax,10ch
mov ds,ax
mov dword ptr ds:[0],0ffffffffh
pop ds
ret
gpset_256 endp
;● PSET のサブルーチン(3万色PSET [512*512ピクセルモード])
;----------------------------------------------------------------------------
gpset_32_3 proc
lea ebx,[ebx*8] ;ebx に ebx*1024+eax*2 を
lea ebx,[ebx*8] ;入れる(VRAM アドレス)
lea ebx,[ebx*8+eax]
lea ebx,[ebx*2]
call gpset32sub
ret
;;★まだつくってないよーん
;push ds
;mov ax,10ch
;mov ds,ax
;mov word ptr ds:[0],07fffh
;pop ds
;ret
gpset_32_3 endp
;● 3万色PSET のサブルーチン
; ebx にオフセット、edx に演算指定、ecx にカラーコードが
; 設定されていることを前提に、
; ベースオフセット加算、セレクタ設定、VRAM への書き込みを行う。
;------------------------------------------------------------------------
gpset32sub proc
; in ebx:画面内アドレス
call __AddVramBase_ebx
push es ;es 保存
call __SetVramSeg ;es ← 書き込みページのセレクタ
or edx,edx ;edx(演算指定) により分岐
jnz #2
mov es:[ebx],cx ;演算 PSET
jmp #3
#2: cmp edx,4
jnz #4
xor es:[ebx],cx ;演算 XOR
jmp #3
#4: cmp edx,6
jnz #3
or cx,cx ;演算 MATTE (0透過)
jz #5
mov es:[ebx],cx
#5: ;
#3: pop es ;es 復帰
ret
gpset32sub endp
cseg ends
end